


import api from '@/util/request'
import { PREFIX } from '@/constant/const'
const urlcode = PREFIX.urlCode // 来源数据中台
const reimburseUrl = PREFIX.reimburse // 来源报账平台
const passport = PREFIX.passport // 来源报账平台


// 获取部门
export function user_GetDept(params) {
  // const others = {}
  // if (params.parentId) {
  //   others.status = 'OPEN'
  // }
  return api.get(passport + "/v1/api/asynLoadDepartment", {
    params: {
      ...params,
    },
  });
}
// 查询用户
export function user_GetUsers(params) {
  return api.get(urlcode + "/v1/api/admin/list", {
    params: {
      projectKey: useMenuOutsideStore().getProjectKey,
      departmentId: params.departmentId,
      name: params.name,
    },
  });
}

// 获取角色
export function user_GetRole(params) {
  return api.get(urlcode + "/v1/api/getRoleList", {
    params: {
      projectKey: useMenuOutsideStore().getProjectKey,
    },
  });
}

// 获取当前公司树 根据登录信息拿到帐号对应的公司
export function userGetConmpanyTree() {
  return api.get(reimburseUrl + "/budgetCategory/getCompanyTree");
}

// 异步获取组织架构树
export function getDepartmentTree(params) {
  return api.get(passport + '/v1/api/asynLoadDepartment', {
    params
  })
}

// 根据登录帐号拿到对应的岗位
export function accountWork(params) {
  return api.get(urlcode + "/v1/api/position", {
    params,
  });
}

// 获取所有组织
export function allCompanyTree(params) {
  return api.get(urlcode + "/v1/api/getDepartmentTree", {
    params,
  });
}

// 获取用户应用
export function userAppList() {
  return new Promise((resolve) => {
    setTimeout(() => {
      let nav = [
        {
          name: "共享管理",
          url: location.origin + "/#/shared",
          projectKey: "ndybqjc6",
          code: "shared",
          target: "current",
        },
        {
          name: "费用共享",
          url: location.origin + "/#/expenseShared",
          projectKey: "dq71mr6v",
          code: "expenseShared",
          target: "current",
        },
        {
          name: "结算",
          url: location.origin + "/#/settlement",
          projectKey: "3py5ufhf",
          code: "settlement",
          target: "current",
        },
        // {
        //   name: "费用共享跳外部",
        //   url: location.origin + "/#/expenseShared",
        //   projectKey: "dq71mr6v",
        //   code: "expenseShared",
        //   target: "new",
        // },
        // {
        //   name: "财数通-报账平台",
        //   url: "http://fssclient-test.sjgo365.com/#/center/main",
        //   projectKey: "40q1xemv",
        //   code: "fssc",
        //   target: "new",
        // },
        // {
        //   name: "排除路由的微应用测试",
        //   url: "http://localhost:9001",
        //   projectKey: "ndybqjc6",
        //   code: "microDesign",
        //   target: "current",
        //   mode: "route",
        // },
        // {
        //   name: "包括路由的器微应用测试",
        //   url: "http://localhost:9001",
        //   projectKey: "40q1xemv",
        //   code: "contentDesign",
        //   target: "current",
        //   mode: "menu_route",
        // },
      ];
      resolve(nav);
    }, 500);
  });
}
